<?php
// 用户管理
namespace Home\Controller;
use Think\Cache\Driver\Redis;
// use Think\Controller;
class UserController extends BaseController {
	public function index(){
		$redis = new Redis();
		$group = $redis->get('group'.$this->app['id']);
		if (!$group) {
			$group = $this->group_list();
			if(is_string($group)) exit($group);
			$redis->set('group'.$this->app['id'], $group,60);
		}
		
		foreach ($group['groups'] as &$v)$count +=$v['count'] ;
		$page = I('page',1);
		$mod = D('User');
		$count = $mod->where(array('subscribe'=>1))->count();
		$data = $mod->where(array('subscribe'=>1))->page($page.',20')->select();
		
		$this->assign('page',$page);
		$this->assign('prev',($page > 1) ? $page-1 : 1);
		$this->assign('next',($page > ceil($count/20)) ? $page+1 : ceil($count/20));
		$this->assign('count',ceil($count/20));
		
		$this->assign('users',$data);
		$this->assign('count',$count);
		$this->assign('group',$group['groups']);
		$this->display();
	}
}
